package entities;

import menu.Settings;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.SlickException;

import util.Vector2D;

public class ShootingEnemy extends Enemy {

	private Weapon weapon;

	public ShootingEnemy(float frequency) throws SlickException {
		super("res/enemies/enemy07.png");
		image = image.getScaledCopy(65, 25);
		weapon = new SimpleWeapon("res/shot.png", 1, this, (int) (1000f / frequency));
		maxHealth = (int) (3 * Settings.getfactor());
		score = 50;
		reset();
	}

	@Override
	public void update(GameContainer gc, int delta) {
		super.update(gc, delta);
		Vector2D shotVel = level.getPlayer().center().subtract(center()).getUnitVector().scale(200).add(velocity.scale(0.5f));
		System.out.println("Shot: " + shotVel.getLength());
		weapon.shoot(shotVel);
	}

	@Override
	public String getName() {
		return "Shooting Enemy";
	}
	
	@Override
	public void reset() {
		super.reset();
		setVelocity(new Vector2D(-100 - random.nextInt(50) , 0));
	}

}
